package com.bibrApp.difu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.bibrApp.difu.R;

import java.util.ArrayList;
import java.util.List;

public class TradeNameSpinnerAdapter extends BaseAdapter {

    Context context;
    List<String> datas = new ArrayList<>();
    private final LayoutInflater inflater;

    public TradeNameSpinnerAdapter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(context);
    }
    public void setDatas(List<String> datas){
        this.datas.clear();
        this.datas.addAll(datas);
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return datas == null ? 0 : datas.size();
    }

    @Override
    public Object getItem(int position) {
        return datas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.item_spinner_evidence, parent, false);
        }
        TextView evidence = (TextView) convertView.findViewById(R.id.spinner_evidence);

        evidence.setText(datas.get(position));
        return convertView;
    }
}
